com.ibm.db2.jcc.am.SqlException:无效操作:结果集已关闭。ERRORCODE=

您所在的位置:网站首页 db2 errorcode=-4470 com.ibm.db2.jcc.am.SqlException:无效操作:结果集已关闭。ERRORCODE=

com.ibm.db2.jcc.am.SqlException:无效操作:结果集已关闭。ERRORCODE=

2024-07-09 19:15| 来源: 网络整理| 查看: 265

我有一个相当简单的portlet,它显示了门户网站的访问者数量(在线,每日,每周,每月,每年)。

在doView方法的portlet类中,我首先调用一个方法,该方法对表进行插入(关于新访问者的信息)。在我逐个调用了5个方法后,这些方法在同一个表上进行计数选择。它们都很相似,只是它们的查询不同。其中一个方法实现如下:

代码语言:javascript复制public static Integer getOnline() { Integer res = null; Statement stmt = null; ResultSet rs = null; try { stmt = getConnection().createStatement(); rs = stmt.executeQuery(query); if (rs.next()) { res = new Integer(rs.getString("1")); } } catch (SQLException e) { log.error("Excepton: " + e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { log.warn("Error closing result set: ", e); } rs = null; } if (stmt != null) { try { stmt.close(); } catch (SQLException e) { log.warn("Error closing statement: ", e); } stmt = null; } } return res; }

获取连接:

代码语言:javascript复制public static Connection getConnection() { try { if (connection == null) { if (dataSource == null) { dataSource = (DataSource) new InitialContext().lookup(dataSourceName); } connection = dataSource.getConnection(); } } catch (Exception e) { log.error("Error on opening a connection: ", e); } return connection; }

连接在doView方法结束时关闭。偶尔我也会遇到这样的异常:

代码语言:javascript复制com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][4.14.88] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null

从选择的一种或几种方法中选择。有时还会出现以下错误:

代码语言:javascript复制com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Connection is closed. com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Statement is closed.

在互联网上搜索后,我仍然没有找到/意识到我的案例中错误的原因是什么,以及如何修复它。任何帮助都将不胜感激。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3